﻿using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace FurStudy.Application
{
    /// <summary>
    /// 自定义验证类
    /// 继承 IValidateOptions<TOptions> 接口
    /// </summary>
    public class AppInfoValidation : IValidateOptions<AppInfoOptions>
    {
        public ValidateOptionsResult Validate(string name, AppInfoOptions options)
        {
            if (!Regex.IsMatch(options.Version, @"^[0-9][0-9\.]+[0-9]$"))
            {
                return ValidateOptionsResult.Fail("不是有效的版本号");
            }
            return ValidateOptionsResult.Success;
        }
    }
}
